home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Incognito / cdev / CListManager.h < prev    next >
Text File  |  1994-02-09  |  3KB  |  94 lines

  1. #ifndef __CLISTMANAGER__
  2. #define __CLISTMANAGER__
  3.  
  4. #ifndef __QUICKDRAW__
  5. #include <Quickdraw.h>
  6. #endif
  7.  
  8. #ifndef __LISTS__
  9. #include <Lists.h>
  10. #endif
  11.  
  12. #ifndef __DIALOGS__
  13. #include <Dialogs.h>
  14. #endif
  15.  
  16. class CListManager : public SingleObject
  17. {
  18.     public:
  19.     
  20.                 CListManager(short dialogItem, DialogPtr theDialog, short width = 1, short height = 0);
  21.                 ~CListManager();
  22.  
  23.         void    AddItem(StringPtr theItem, Cell theCell);
  24.         void    RemoveItem(Cell theCell);
  25.         void    RemoveItem(StringPtr theItem);
  26.         Boolean GetItem(StringPtr theData, Cell &theCell);
  27.         void    SetItem(StringPtr theString, Cell theCell);
  28.         Boolean InsertItem(StringPtr theItem);
  29.         
  30.         Boolean    FindItem(StringPtr theItem, Cell &theCell);
  31.         Boolean    FindNextSelection(Cell &theCell);
  32.  
  33.         /*
  34.             iterators. Call GetFirstItem to get the cell
  35.             and data of the first item; call GetNextItem to
  36.             iterate over the rest. They return true if the item is
  37.             real.
  38.         */
  39.         Boolean    GetFirstItem(StringPtr theItem, Cell &theCell);
  40.         Boolean    GetNextItem(StringPtr theItem, Cell &theCell);
  41.                                                                 
  42.         void    DeselectList();
  43.         void    SelectItem(StringPtr theItem);
  44.         
  45.         Boolean    IsSelection();
  46.         Boolean    IsSelection(Cell &theCell);                    // is an item selected
  47.         Boolean    IsItemPresent(StringPtr theItem);
  48.         Boolean    IsItemSelected(Cell &theCell);
  49.         Boolean    IsItemSelected(StringPtr theItem);
  50.         Boolean    GetCurrentSelection(StringPtr theItem);
  51.         void    SelectItem(Cell &theCell);
  52.         void    DeselectItem(Cell &theCell);
  53.         void    DeleteSelection(void);
  54.  
  55.         void    Update();
  56.         void    Activate();
  57.         void    Deactivate();
  58.         void    AutoScroll();
  59.         void    Empty();
  60.         void    DoDraw(Boolean drawStuff = true);
  61.         Boolean    IsEmpty() {return !GetHeight();}
  62.         Boolean    Click(Point thePoint, short modifiers);
  63.     
  64.         inline    short    GetHeight();
  65.         inline    short    GetWidth();
  66.     
  67.         void    SetList(ListHandle theList) {fTheList = theList;}
  68.         Boolean BinarySearchInsensitive(StringPtr theItem, Cell &theCell);
  69.         ListHandle    GetList() {return fTheList;}
  70.  
  71.     protected:
  72.     
  73.         ListHandle    fTheList;
  74.  
  75.         /*
  76.             Compare function for LFind speediness. Override if you want, since
  77.             this only checks the whole string. In theory, you could use this 2
  78.             implement user-typed selections.
  79.         */
  80.         short    CompareInfo(Cell theCell, short offset, short length, StringPtr theData);
  81.         
  82.         /*
  83.             BinarySearch returns true if the item isn't in the list, false if it
  84.             is. Kinda backwards, but hey. It's the MAIN searching procedure, used
  85.             both by FindItem and InsertItem. Speedy, I guess. It was just nicer to
  86.             have this binary search instead of Ye Olde Linear search that LSearch
  87.             uses.
  88.         */
  89.         Boolean    BinarySearch(StringPtr theItem, Cell &theCell);
  90.  
  91.  
  92. };
  93. #endif
  94.